//
//  Tool.swift
//  DSP
//
//  Created by tucici on 2024/6/12.
//

import UIKit
import TCCKit
///一些控件的状态管理
class Tool {
    class func inputStatus(_ enable:Bool,_ input:UITextField){
        input.isEnabled = enable
        input.textHexColor = enable ? HEX_BLACK : HEX_TEXT_DISABLE
    }
    
    class func labelNormal(_ lbl:UILabel){
        status(lbl, 1)
        
    }
    class func labelHightlight(_ lbl:UILabel){
        status(lbl, 2)
    }
    class func labelDisable(_ lbl:UILabel){
        status(lbl, 3)
    }
    
    /// UIButton正常状态
    class func btnNormal(_ sender:UIButton){
        sender.isEnabled = true
        status(sender, 1)
    }
    
    /// UIButton高亮状态
    class func btnHightlight(_ sender:UIButton){
        sender.isEnabled = true
        status(sender, 2)
    }
    
    /// UIButton禁止状态
    class func btnDisable(_ sender:UIButton){
        sender.isEnabled = false
        status(sender, 3)
    }
    
    ///视图的三种状态，1 = normal  2 =  hightlight  3 = disable
    private class func status(_ sender:UIView, _ status:Int){
        switch status{
        case 1 :
            sender.isUserInteractionEnabled = true
            sender.bgHexColor = HEX_BG
            sender.textHexColor = HEX_BLACK
            sender.borderHexColor = HEX_BLACK
        case 2:
            sender.isUserInteractionEnabled = true
            sender.bgHexColor = HEX_RED
            sender.textHexColor = HEX_WHITE
            sender.borderHexColor = HEX_RED
        case 3:
            sender.isUserInteractionEnabled = false
            sender.bgHexColor = HEX_BG_DISABLE
            sender.textHexColor = HEX_TEXT_DISABLE
            sender.borderHexColor = HEX_BORDER_DISABLE
        default:
            break
        }
    }
    
}
